Contents | Index | < Browse | Browse >

LETTERfreopenULETTER Reopens a file.

Overview
#include <stdio.h>

fp = freopen(name, mode, file);

FILE *fp;
const char *name;
const char *mode;
FILE *f;

Portability
ANSI

Description
This function is used to redirect an opened file. That is, the file pointed to by "f" is closed, and a new file is created which will be attached to "f"'s "FILE" structure.

Do not use this function to redirect the standard streams stdin and stdout as these must not be closed (which would happen by using freopen).

Returns
If an error occured, NULL is returned, otherwise "f" which then points to the new file.